FHIR © HL7.org  |  Server Home  |  FHIR Server FHIR Server 3.7.16  |  FHIR Version n/a  User: [n/a]

Resource StructureMap/FHIR Server from package ch.fhir.ig.cda-fhir-maps#0.3.0 (141 ms)

Package ch.fhir.ig.cda-fhir-maps
Type StructureMap
Id Id
FHIR Version R4
Source http://fhir.ch/ig/cda-fhir-maps/http://fhir.ch/ig/cda-fhir-maps/StructureMap-BundleToCdaCh.html
Url http://fhir.ch/ig/cda-fhir-maps/StructureMap/BundleToCdaCh
Version 0.3.0
Status draft
Date 2022-02-11T11:14:39+01:00
Name BundleToCdaCh
Experimental False
Realm ch
Authority hl7
Description CDA-CH document, 2.16.756.5.30.1.1.10.1.14 2020-01-16 Oliver Egger, copyright ahdis ag, Apache License CDA-CH: https://art-decor.org/art-decor/decor-templates--hl7chcda- FHIR CH-Core: http://fhir.ch/ig/ch-core/index.html
Copyright CC-BY-SA-4.0

Resources that use this resource

No resources found


Resources that this resource uses

No resources found



Narrative

Note: links and images are rebased to the (stated) source

map "http://fhir.ch/ig/cda-fhir-maps/StructureMap/BundleToCdaCh" = "BundleToCdaCh"


// CDA-CH document, 2.16.756.5.30.1.1.10.1.14
// 2020-01-16 Oliver Egger, copyright ahdis ag, Apache License
// CDA-CH:  https://art-decor.org/art-decor/decor-templates--hl7chcda-
// FHIR CH-Core: http://fhir.ch/ig/ch-core/index.html

uses "http://hl7.org/fhir/cda/StructureDefinition/ClinicalDocument" alias ClinicalDocument as target
uses "http://hl7.org/fhir/cda/StructureDefinition/Author" alias Author as target
uses "http://hl7.org/fhir/cda/StructureDefinition/RecordTarget" alias RecordTarget as target
uses "http://hl7.org/fhir/cda/StructureDefinition/DataEnterer" alias DataEnterer as target
uses "http://hl7.org/fhir/cda/StructureDefinition/AssignedEntity" alias AssignedEntity as target
uses "http://hl7.org/fhir/StructureDefinition/Bundle" alias Bundle as source
uses "http://hl7.org/fhir/StructureDefinition/Composition" alias Composition as source
uses "http://hl7.org/fhir/StructureDefinition/Person" alias Person as source

imports "http://fhir.ch/ig/cda-fhir-maps/StructureMap/FhirToCdaTypes"
imports "http://fhir.ch/ig/cda-fhir-maps/StructureMap/BundleToCda"

// source: http://build.fhir.org/ig/hl7ch/ch-core/branches/master/StructureDefinition-ch-core-document.html
// target: https://art-decor.org/art-decor/decor-templates--hl7chcda-?id=2.16.756.5.30.1.1.10.1.14
group BundleToCdaCh(source bundle : Bundle, target cda : ClinicalDocument) {
  bundle ->  cda.recordTarget as recordTarget,  cda.author as author then BundleToClinicalDocumentCh(bundle, recordTarget, author, cda) "bundle";
}

// source: http://build.fhir.org/ig/hl7ch/ch-core/branches/master/StructureDefinition-ch-core-document.html
// target: https://art-decor.org/art-decor/decor-templates--hl7chcda-?id=2.16.756.5.30.1.1.10.1.14
group BundleToClinicalDocumentCh(source bundle : Bundle, target recordTarget : RecordTarget, target author : Author, target cda : ClinicalDocument) extends BundleToClinicalDocument {
  bundle ->  author.templateId as templateId,  templateId.root = '2.16.756.5.30.1.1.10.9.23' "tempalteId";
  bundle ->  recordTarget.templateId as templateId,  templateId.root = '2.16.756.5.30.1.1.10.2.1' "tempalteId";
  bundle ->  cda.custodian as custodian,  custodian.templateId as templateId,  templateId.root = '2.16.756.5.30.1.1.10.2.3' "tempalteId";
  bundle -> cda.realmCode as realmCode then {
    bundle -> realmCode.code = 'CHE' "CHE";
  } "realmCode";
  bundle -> cda.templateId as templateId then {
    bundle -> templateId.root = '2.16.756.5.30.1.1.10.1.9' "root";
  } "0-structuredBody";
  bundle -> cda.templateId as templateId then {
    bundle -> templateId.root = '2.16.840.1.113883.10.12.2' "root";
  } "componentAsStructuredBody";
  bundle -> cda.templateId as templateId then {
    bundle -> templateId.root = '2.16.840.1.113883.10.12.1' "root";
  } "HL7CdaR2-2005";
  bundle.entry as entry then {
    entry.resource as resource where $this.ofType(FHIR.Composition) then CompositionClinicalDocumentCH(bundle, resource, cda);
  };
}

// _________________________ Section Level Templates _________________________
// source: http://build.fhir.org/ig/hl7ch/ch-core/branches/master/StructureDefinition-ch-core-composition-definitions.html#Composition.section
// target: https://art-decor.org/art-decor/decor-templates--hl7chcda-?id=2.16.756.5.30.1.1.10.3.2
group SectionCdaRemarksCoded(source bundle : Bundle, source section : Section, target cdasection : CdaSection) extends SectionCdaSection {
  section ->  cdasection.templateId as templateId,  templateId.root = '2.16.756.5.30.1.1.10.3.2' "templateId";
  section ->  cdasection.entry as entry,  entry.act as act,  act.classCode = 'ACT',  act.moodCode = 'EVN' then {
    section ->  act.templateId as templateId,  templateId.root = '2.16.756.5.30.1.1.10.4.2' "templateId";
    section ->  act.templateId as templateId,  templateId.root = '2.16.840.1.113883.10.20.1.40' "templateId";
    section ->  act.templateId as templateId,  templateId.root = '1.3.6.1.4.1.19376.1.5.3.1.4.2' "templateId";
    section ->  act.code as code,  code.code = '48767-8',  code.codeSystem = '2.16.840.1.113883.6.1',  code.codeSystemName = 'LOINC',  code.displayName = 'Annotation comment' "code";
    // <span id="co1">
    section.text as text then {
      text.div as div ->  act.text as text,  text.reference as reference,  reference.value = ('#' + %div.substring(%div.indexOf('id') + %div.substring(%div.indexOf('id')).indexOf('\"') + 1, %div.substring(%div.indexOf('id') + %div.substring(%div.indexOf('id')).indexOf('\"') + 1).indexOf('\"'))) "id";
    };
    section ->  act.statusCode as statusCode,  statusCode.code = 'completed' "completed";
  } "entry";
}

group SectionCdaOriginalRepresentationObservationMedia(source binary : Binary, source section : Section, target cdasection : CdaSection) {
  section -> cdasection.text = '<div xmlns=\"http://www.w3.org/1999/xhtml\">Representation of the original view:<img src=\"pdf1\"/></div>' "Section";
  section -> cdasection.entry as entry then {
    binary -> entry.typeCode = 'DRIV' "driv";
    binary ->  entry.observationMedia as observationMedia,  observationMedia.classCode = 'OBS',  observationMedia.moodCode = 'EVN' then {
      binary ->  observationMedia.templateId as templateId,  templateId.root = '2.16.756.5.30.1.1.10.4.83' "templateId";
      binary -> observationMedia.ID = 'pdf1' "reference";
      binary ->  observationMedia.value as value,  value.mediaType = '2.16.756.5.30.1.1.10.4.83',  value.representation = 'B64' then {
        binary.contentType as contentType -> value.mediaType = contentType;
        binary.data as data -> value.data = data;
        binary.language as lang ->  observationMedia.languageCode as languageCode,  languageCode.code = lang "lang";
        binary where $this.language.exists() = false ->  observationMedia.languageCode as languageCode,  languageCode.nullFlavor = 'UNK' "langUnknown";
      } "value";
    } "observationMedia";
  } "entry";
}

// source: http://build.fhir.org/ig/hl7ch/ch-core/branches/master/StructureDefinition-ch-core-composition-definitions.html#Composition.section
// target: https://art-decor.org/art-decor/decor-templates--hl7chcda-?id=2.16.756.5.30.1.1.10.1.14
// target: https://art-decor.org/art-decor/decor-templates--hl7chcda-?id=2.16.756.5.30.1.1.10.4.83
group SectionCdaOriginalRepresentation(source bundle : Bundle, source section : Section, target cdasection : CdaSection) extends SectionCdaSection {
  section ->  cdasection.templateId as templateId,  templateId.root = '2.16.756.5.30.1.1.10.3.45' "templateId";
  section where title.exists().not() then {
    section where (%bundle.entry[0].resource.language.startsWith('de')) ->  cdasection.title as title,  title.data = 'Original Darstellung' "titleDE";
    section where (%bundle.entry[0].resource.language.startsWith('fr')) ->  cdasection.title as title,  title.data = 'Représentation originale' "titleFR";
    section where (%bundle.entry[0].resource.language.startsWith('it')) ->  cdasection.title as title,  title.data = 'Rappresentazione originale' "titleIT";
    section where (%bundle.entry[0].resource.language.startsWith('en')) ->  cdasection.title as title,  title.data = 'Original representation' "titleEN";
  } "defaulttitles";
  bundle.entry as entry then {
    entry.fullUrl where ($this in %section.entry.reference) and $this.startsWith('urn:uuid') then {
      entry.resource as binary then SectionCdaOriginalRepresentationObservationMedia(binary, section, cdasection) "patient";
    } "fullUrlAsUuid";
    entry.resource as binary where ('Binary' + '/' + $this.id) in %section.entry.reference then SectionCdaOriginalRepresentationObservationMedia(binary, section, cdasection) "patient";
  } "patient";
}

// _________________________ Entry Level Templates   ________________________
// _________________________ Header Level Templates _________________________
// source: http://build.fhir.org/ig/hl7ch/ch-core/branches/master/StructureDefinition-ch-core-composition-epr.html
// target: https://art-decor.org/art-decor/decor-templates--hl7chcda-?id=2.16.756.5.30.1.1.10.9.12
group PersonAssignedEntityWithId(source practitioner : Practitioner, target assignedEntity : AssignedEntity) {
  practitioner.identifier as identifier -> assignedEntity.id as id then IdentifierII(identifier, id);
  practitioner.address as address -> assignedEntity.addr as addr then AddressAD(address, addr);
  practitioner.name as humanname ->  assignedEntity.assignedPerson as assignedPerson,  assignedPerson.name as en then HumanNameEN(humanname, en);
}

// source: http://build.fhir.org/ig/hl7ch/ch-core/branches/master/StructureDefinition-ch-core-composition-epr.html
// target: https://art-decor.org/art-decor/decor-templates--hl7chcda-?id=2.16.756.5.30.1.1.10.9.12
group DataEnterer(source bundle : Bundle, source practitionerRole : PractitionerRole, target assignedEntity : AssignedEntity) {
  practitionerRole.practitioner as practitioner then {
    practitioner.reference as reference then {
      bundle.entry as entry then {
        entry.fullUrl where ($this in %reference.value) and $this.startsWith('urn:uuid') then {
          entry.resource : Practitioner as practitioner then PersonAssignedEntityWithId(practitioner, assignedEntity) "AssignedEntityWithId";
        } "uuid";
        entry.resource : Practitioner as practitioner where ('Practitioner' + '/' + $this.id) in %reference.value then PersonAssignedEntityWithId(practitioner, assignedEntity) "AssignedEntityWithId";
      } "practitioner";
    } "valueReference";
  } "extensionPerson";
  practitionerRole.organization as organization -> assignedEntity.representedOrganization as representedOrganization then {
    organization.reference as reference then {
      bundle.entry as entry then {
        entry.fullUrl where ($this in %reference.value) and $this.startsWith('urn:uuid') then {
          entry.resource : Organization as organization then Organization2CdaOrganization(organization, representedOrganization) "representedOrganization";
        } "uuid";
        entry.resource : Organization as organization where ('Organization' + '/' + $this.id) in %reference.value then Organization2CdaOrganization(organization, representedOrganization) "representedOrganization";
      } "practitioner";
    } "valueReference";
  } "extensionPerson";
}

// _________________________ Template Type not specified  ___________________
// source: http://hl7.org/fhir/R4/person.html
// target: https://art-decor.org/art-decor/decor-templates--hl7chcda-?id=2.16.756.5.30.1.1.10.9.36
group CompositionClinicalDocumentCH(source bundle : Bundle, source composition : Composition, target cda : ClinicalDocument) {
  composition.type as type then {
    type.coding as coding where $this.system = 'http://snomed.info/sct' ->  cda.code as code,  code.translation as translation then CodingCE(coding, translation) "translation";
  };
  composition.confidentiality as conf where $this.extension.where(url = 'http://fhir.ch/ig/ch-core/StructureDefinition/ch-ext-epr-confidentialitycode').exists() -> cda.confidentialityCode as cdaconf then {
    conf.extension as extension then {
      extension.valueCodeableConcept as valueCodeableConcept then {
        valueCodeableConcept.coding as coding then CodingCE(coding, cdaconf);
      };
    };
  } "confidentialityCode";
  // If setId exists as Composition.ch-ext-epr-setid, then map to ClinicalDocument.setId
  composition.identifier as identifier where $this.system = 'urn:ietf:rfc:3986' -> cda.setId as setId then IdentifierII(identifier, setId) "IdentifierII";
  // If setId doesn't exist, used bundle.identifer
  composition where $this.identifier.where(system = 'urn:ietf:rfc:3986').exists() = false then {
    bundle.identifier as identifier -> cda.setId as id then IdentifierII(identifier, id) "setId";
  } "setIdCreated";
  // If versionNumber exists as Composition.ch-ext-epr-versionnumber, then map to ClinicalDocument.versionNumber
  composition.extension as ext where $this.url = 'http://fhir.ch/ig/ch-core/StructureDefinition/ch-ext-epr-versionnumber' -> cda.versionNumber as versionNumber then {
    ext.valueUnsignedInt as valueUnsignedInt then IntegerINT(valueUnsignedInt, versionNumber) "IntegerInt";
  } "versionNumberMapped";
  // If versionNumber doesn't exist, create ClinicalDocument.versionNumber = 1
  composition as composition where $this.extension.where(url = 'http://fhir.ch/ig/ch-core/StructureDefinition/ch-ext-epr-versionnumber').exists() = false -> cda.versionNumber as versionNumber then {
    composition -> versionNumber.value = '1' "versionNumber";
  } "versionNumberCreated";
  composition.extension as extension where $this.url = 'http://fhir.ch/ig/ch-core/StructureDefinition/ch-ext-epr-informationrecipient' -> cda.informationRecipient as informationRecipient then {
    extension -> informationRecipient.typeCode = 'PRCP' "PRCP";
    extension ->  informationRecipient.templateId as templateId,  templateId.root = '2.16.756.5.30.1.1.10.2.4' "templateId";
    extension.valueReference as valueReference then {
      bundle.entry as entry then {
        entry.fullUrl where ($this in %valueReference.reference) and $this.startsWith('urn:uuid') then {
          entry.resource : Patient as patient -> informationRecipient.intendedRecipient as intendedRecipient share intendedRecipient then {
            patient.address as address -> intendedRecipient.addr as addr then AddressAD(address, addr);
            patient.name as humanname ->  intendedRecipient.informationRecipient as informationRecipient2,  informationRecipient2.name as en then HumanNameEN(humanname, en);
          } "fullUrlPatient";
          entry.resource : Organization as organization ->  informationRecipient.intendedRecipient as intendedRecipient share intendedRecipient,  intendedRecipient.receivedOrganization as receivedOrganization then Organization2CdaOrganization(organization, receivedOrganization) "organization";
        } "uuid";
        entry.resource : Patient as patient where (($this.id = %valueReference.reference.substring(8)) or ($this.id = %valueReference.reference.substring(9))) -> informationRecipient.intendedRecipient as intendedRecipient share intendedRecipient then {
          patient.address as address -> intendedRecipient.addr as addr then AddressAD(address, addr);
          patient.name as humanname ->  intendedRecipient.informationRecipient as informationRecipient2,  informationRecipient2.name as en then HumanNameEN(humanname, en);
        } "intendedRecipient";
        entry.resource : Organization as organization where (($this.id = %valueReference.reference.substring(13)) or ($this.id = %valueReference.reference.substring(9))) ->  informationRecipient.intendedRecipient as intendedRecipient share intendedRecipient,  intendedRecipient.receivedOrganization as receivedOrganization then Organization2CdaOrganization(organization, receivedOrganization) "organization";
      };
    };
  } "informationRecipient";
  composition.extension as extension where $this.url = 'http://fhir.ch/ig/ch-core/StructureDefinition/ch-ext-epr-dataenterer' -> cda.dataEnterer as dataEnterer then {
    extension ->  dataEnterer.templateId as templateId,  templateId.root = '2.16.756.5.30.1.1.10.2.7' "templateId";
    extension.extension as extensionTime where $this.url = 'http://fhir.ch/ig/ch-core/StructureDefinition/ch-ext-epr-time' then {
      extensionTime.valueDateTime as valueDateTime -> dataEnterer.time as time then DateTimeTS(valueDateTime, time) "DateTime";
    } "extensionTime";
    extension.extension as extensionPerson where $this.url = 'enterer' then {
      extensionPerson.valueReference as valueReference then {
        bundle.entry as entry then {
          entry.fullUrl where ($this in %valueReference.reference) and $this.startsWith('urn:uuid') then {
            entry.resource : PractitionerRole as practitionerRole -> dataEnterer.assignedEntity as assignedEntity then DataEnterer(bundle, practitionerRole, assignedEntity) "AssignedEntityWithId";
          } "uuid";
          entry.resource : PractitionerRole as practitionerRole where ('PractitionerRole' + '/' + $this.id) in %valueReference.reference -> dataEnterer.assignedEntity as assignedEntity then DataEnterer(bundle, practitionerRole, assignedEntity) "AssignedEntityWithId";
        } "practitioner";
      };
    } "extensionPerson";
  } "dataEnterer";
}


Source

{
  "resourceType" : "StructureMap",
  "id" : "BundleToCdaCh",
  "meta" : {
    "versionId" : "3",
    "lastUpdated" : "2021-11-04T13:44:54.811+01:00"
  },
  "text" : {
    "status" : "generated",
    "div" : "<div xmlns=\"http://www.w3.org/1999/xhtml\">\n <pre>map &quot;http://fhir.ch/ig/cda-fhir-maps/StructureMap/BundleToCdaCh&quot; = &quot;BundleToCdaCh&quot;\n\n\n// CDA-CH document, 2.16.756.5.30.1.1.10.1.14\n// 2020-01-16 Oliver Egger, copyright ahdis ag, Apache License\n// CDA-CH: https://art-decor.org/art-decor/decor-templates--hl7chcda-\n// FHIR CH-Core: http://fhir.ch/ig/ch-core/index.html\n\nuses &quot;http://hl7.org/fhir/cda/StructureDefinition/ClinicalDocument&quot; alias ClinicalDocument as target\nuses &quot;http://hl7.org/fhir/cda/StructureDefinition/Author&quot; alias Author as target\nuses &quot;http://hl7.org/fhir/cda/StructureDefinition/RecordTarget&quot; alias RecordTarget as target\nuses &quot;http://hl7.org/fhir/cda/StructureDefinition/DataEnterer&quot; alias DataEnterer as target\nuses &quot;http://hl7.org/fhir/cda/StructureDefinition/AssignedEntity&quot; alias AssignedEntity as target\nuses &quot;http://hl7.org/fhir/StructureDefinition/Bundle&quot; alias Bundle as source\nuses &quot;http://hl7.org/fhir/StructureDefinition/Composition&quot; alias Composition as source\nuses &quot;http://hl7.org/fhir/StructureDefinition/Person&quot; alias Person as source\n\nimports &quot;http://fhir.ch/ig/cda-fhir-maps/StructureMap/FhirToCdaTypes&quot;\nimports &quot;http://fhir.ch/ig/cda-fhir-maps/StructureMap/BundleToCda&quot;\n\n// source: http://build.fhir.org/ig/hl7ch/ch-core/branches/master/StructureDefinition-ch-core-document.html\n// target: https://art-decor.org/art-decor/decor-templates--hl7chcda-?id=2.16.756.5.30.1.1.10.1.14\ngroup BundleToCdaCh(source bundle : Bundle, target cda : ClinicalDocument) {\n bundle -&gt; cda.recordTarget as recordTarget, cda.author as author then BundleToClinicalDocumentCh(bundle, recordTarget, author, cda) &quot;bundle&quot;;\n}\n\n// source: http://build.fhir.org/ig/hl7ch/ch-core/branches/master/StructureDefinition-ch-core-document.html\n// target: https://art-decor.org/art-decor/decor-templates--hl7chcda-?id=2.16.756.5.30.1.1.10.1.14\ngroup BundleToClinicalDocumentCh(source bundle : Bundle, target recordTarget : RecordTarget, target author : Author, target cda : ClinicalDocument) extends BundleToClinicalDocument {\n bundle -&gt; author.templateId as templateId, templateId.root = '2.16.756.5.30.1.1.10.9.23' &quot;tempalteId&quot;;\n bundle -&gt; recordTarget.templateId as templateId, templateId.root = '2.16.756.5.30.1.1.10.2.1' &quot;tempalteId&quot;;\n bundle -&gt; cda.custodian as custodian, custodian.templateId as templateId, templateId.root = '2.16.756.5.30.1.1.10.2.3' &quot;tempalteId&quot;;\n bundle -&gt; cda.realmCode as realmCode then {\n bundle -&gt; realmCode.code = 'CHE' &quot;CHE&quot;;\n } &quot;realmCode&quot;;\n bundle -&gt; cda.templateId as templateId then {\n bundle -&gt; templateId.root = '2.16.756.5.30.1.1.10.1.9' &quot;root&quot;;\n } &quot;0-structuredBody&quot;;\n bundle -&gt; cda.templateId as templateId then {\n bundle -&gt; templateId.root = '2.16.840.1.113883.10.12.2' &quot;root&quot;;\n } &quot;componentAsStructuredBody&quot;;\n bundle -&gt; cda.templateId as templateId then {\n bundle -&gt; templateId.root = '2.16.840.1.113883.10.12.1' &quot;root&quot;;\n } &quot;HL7CdaR2-2005&quot;;\n bundle.entry as entry then {\n entry.resource as resource where $this.ofType(FHIR.Composition) then CompositionClinicalDocumentCH(bundle, resource, cda);\n };\n}\n\n// _________________________ Section Level Templates _________________________\n// source: http://build.fhir.org/ig/hl7ch/ch-core/branches/master/StructureDefinition-ch-core-composition-definitions.html#Composition.section\n// target: https://art-decor.org/art-decor/decor-templates--hl7chcda-?id=2.16.756.5.30.1.1.10.3.2\ngroup SectionCdaRemarksCoded(source bundle : Bundle, source section : Section, target cdasection : CdaSection) extends SectionCdaSection {\n section -&gt; cdasection.templateId as templateId, templateId.root = '2.16.756.5.30.1.1.10.3.2' &quot;templateId&quot;;\n section -&gt; cdasection.entry as entry, entry.act as act, act.classCode = 'ACT', act.moodCode = 'EVN' then {\n section -&gt; act.templateId as templateId, templateId.root = '2.16.756.5.30.1.1.10.4.2' &quot;templateId&quot;;\n section -&gt; act.templateId as templateId, templateId.root = '2.16.840.1.113883.10.20.1.40' &quot;templateId&quot;;\n section -&gt; act.templateId as templateId, templateId.root = '1.3.6.1.4.1.19376.1.5.3.1.4.2' &quot;templateId&quot;;\n section -&gt; act.code as code, code.code = '48767-8', code.codeSystem = '2.16.840.1.113883.6.1', code.codeSystemName = 'LOINC', code.displayName = 'Annotation comment' &quot;code&quot;;\n // &lt;span id=&quot;co1&quot;&gt;\n section.text as text then {\n text.div as div -&gt; act.text as text, text.reference as reference, reference.value = ('#' + %div.substring(%div.indexOf('id') + %div.substring(%div.indexOf('id')).indexOf('\\&quot;') + 1, %div.substring(%div.indexOf('id') + %div.substring(%div.indexOf('id')).indexOf('\\&quot;') + 1).indexOf('\\&quot;'))) &quot;id&quot;;\n };\n section -&gt; act.statusCode as statusCode, statusCode.code = 'completed' &quot;completed&quot;;\n } &quot;entry&quot;;\n}\n\ngroup SectionCdaOriginalRepresentationObservationMedia(source binary : Binary, source section : Section, target cdasection : CdaSection) {\n section -&gt; cdasection.text = '&lt;div xmlns=\\&quot;http://www.w3.org/1999/xhtml\\&quot;&gt;Representation of the original view:&lt;img src=\\&quot;pdf1\\&quot;/&gt;&lt;/div&gt;' &quot;Section&quot;;\n section -&gt; cdasection.entry as entry then {\n binary -&gt; entry.typeCode = 'DRIV' &quot;driv&quot;;\n binary -&gt; entry.observationMedia as observationMedia, observationMedia.classCode = 'OBS', observationMedia.moodCode = 'EVN' then {\n binary -&gt; observationMedia.templateId as templateId, templateId.root = '2.16.756.5.30.1.1.10.4.83' &quot;templateId&quot;;\n binary -&gt; observationMedia.ID = 'pdf1' &quot;reference&quot;;\n binary -&gt; observationMedia.value as value, value.mediaType = '2.16.756.5.30.1.1.10.4.83', value.representation = 'B64' then {\n binary.contentType as contentType -&gt; value.mediaType = contentType;\n binary.data as data -&gt; value.data = data;\n binary.language as lang -&gt; observationMedia.languageCode as languageCode, languageCode.code = lang &quot;lang&quot;;\n binary where $this.language.exists() = false -&gt; observationMedia.languageCode as languageCode, languageCode.nullFlavor = 'UNK' &quot;langUnknown&quot;;\n } &quot;value&quot;;\n } &quot;observationMedia&quot;;\n } &quot;entry&quot;;\n}\n\n// source: http://build.fhir.org/ig/hl7ch/ch-core/branches/master/StructureDefinition-ch-core-composition-definitions.html#Composition.section\n// target: https://art-decor.org/art-decor/decor-templates--hl7chcda-?id=2.16.756.5.30.1.1.10.1.14\n// target: https://art-decor.org/art-decor/decor-templates--hl7chcda-?id=2.16.756.5.30.1.1.10.4.83\ngroup SectionCdaOriginalRepresentation(source bundle : Bundle, source section : Section, target cdasection : CdaSection) extends SectionCdaSection {\n section -&gt; cdasection.templateId as templateId, templateId.root = '2.16.756.5.30.1.1.10.3.45' &quot;templateId&quot;;\n section where title.exists().not() then {\n section where (%bundle.entry[0].resource.language.startsWith('de')) -&gt; cdasection.title as title, title.data = 'Original Darstellung' &quot;titleDE&quot;;\n section where (%bundle.entry[0].resource.language.startsWith('fr')) -&gt; cdasection.title as title, title.data = 'Représentation originale' &quot;titleFR&quot;;\n section where (%bundle.entry[0].resource.language.startsWith('it')) -&gt; cdasection.title as title, title.data = 'Rappresentazione originale' &quot;titleIT&quot;;\n section where (%bundle.entry[0].resource.language.startsWith('en')) -&gt; cdasection.title as title, title.data = 'Original representation' &quot;titleEN&quot;;\n } &quot;defaulttitles&quot;;\n bundle.entry as entry then {\n entry.fullUrl where ($this in %section.entry.reference) and $this.startsWith('urn:uuid') then {\n entry.resource as binary then SectionCdaOriginalRepresentationObservationMedia(binary, section, cdasection) &quot;patient&quot;;\n } &quot;fullUrlAsUuid&quot;;\n entry.resource as binary where ('Binary' + '/' + $this.id) in %section.entry.reference then SectionCdaOriginalRepresentationObservationMedia(binary, section, cdasection) &quot;patient&quot;;\n } &quot;patient&quot;;\n}\n\n// _________________________ Entry Level Templates ________________________\n// _________________________ Header Level Templates _________________________\n// source: http://build.fhir.org/ig/hl7ch/ch-core/branches/master/StructureDefinition-ch-core-composition-epr.html\n// target: https://art-decor.org/art-decor/decor-templates--hl7chcda-?id=2.16.756.5.30.1.1.10.9.12\ngroup PersonAssignedEntityWithId(source practitioner : Practitioner, target assignedEntity : AssignedEntity) {\n practitioner.identifier as identifier -&gt; assignedEntity.id as id then IdentifierII(identifier, id);\n practitioner.address as address -&gt; assignedEntity.addr as addr then AddressAD(address, addr);\n practitioner.name as humanname -&gt; assignedEntity.assignedPerson as assignedPerson, assignedPerson.name as en then HumanNameEN(humanname, en);\n}\n\n// source: http://build.fhir.org/ig/hl7ch/ch-core/branches/master/StructureDefinition-ch-core-composition-epr.html\n// target: https://art-decor.org/art-decor/decor-templates--hl7chcda-?id=2.16.756.5.30.1.1.10.9.12\ngroup DataEnterer(source bundle : Bundle, source practitionerRole : PractitionerRole, target assignedEntity : AssignedEntity) {\n practitionerRole.practitioner as practitioner then {\n practitioner.reference as reference then {\n bundle.entry as entry then {\n entry.fullUrl where ($this in %reference.value) and $this.startsWith('urn:uuid') then {\n entry.resource : Practitioner as practitioner then PersonAssignedEntityWithId(practitioner, assignedEntity) &quot;AssignedEntityWithId&quot;;\n } &quot;uuid&quot;;\n entry.resource : Practitioner as practitioner where ('Practitioner' + '/' + $this.id) in %reference.value then PersonAssignedEntityWithId(practitioner, assignedEntity) &quot;AssignedEntityWithId&quot;;\n } &quot;practitioner&quot;;\n } &quot;valueReference&quot;;\n } &quot;extensionPerson&quot;;\n practitionerRole.organization as organization -&gt; assignedEntity.representedOrganization as representedOrganization then {\n organization.reference as reference then {\n bundle.entry as entry then {\n entry.fullUrl where ($this in %reference.value) and $this.startsWith('urn:uuid') then {\n entry.resource : Organization as organization then Organization2CdaOrganization(organization, representedOrganization) &quot;representedOrganization&quot;;\n } &quot;uuid&quot;;\n entry.resource : Organization as organization where ('Organization' + '/' + $this.id) in %reference.value then Organization2CdaOrganization(organization, representedOrganization) &quot;representedOrganization&quot;;\n } &quot;practitioner&quot;;\n } &quot;valueReference&quot;;\n } &quot;extensionPerson&quot;;\n}\n\n// _________________________ Template Type not specified ___________________\n// source: http://hl7.org/fhir/R4/person.html\n// target: https://art-decor.org/art-decor/decor-templates--hl7chcda-?id=2.16.756.5.30.1.1.10.9.36\ngroup CompositionClinicalDocumentCH(source bundle : Bundle, source composition : Composition, target cda : ClinicalDocument) {\n composition.type as type then {\n type.coding as coding where $this.system = 'http://snomed.info/sct' -&gt; cda.code as code, code.translation as translation then CodingCE(coding, translation) &quot;translation&quot;;\n };\n composition.confidentiality as conf where $this.extension.where(url = 'http://fhir.ch/ig/ch-core/StructureDefinition/ch-ext-epr-confidentialitycode').exists() -&gt; cda.confidentialityCode as cdaconf then {\n conf.extension as extension then {\n extension.valueCodeableConcept as valueCodeableConcept then {\n valueCodeableConcept.coding as coding then CodingCE(coding, cdaconf);\n };\n };\n } &quot;confidentialityCode&quot;;\n // If setId exists as Composition.ch-ext-epr-setid, then map to ClinicalDocument.setId\n composition.identifier as identifier where $this.system = 'urn:ietf:rfc:3986' -&gt; cda.setId as setId then IdentifierII(identifier, setId) &quot;IdentifierII&quot;;\n // If setId doesn't exist, used bundle.identifer\n composition where $this.identifier.where(system = 'urn:ietf:rfc:3986').exists() = false then {\n bundle.identifier as identifier -&gt; cda.setId as id then IdentifierII(identifier, id) &quot;setId&quot;;\n } &quot;setIdCreated&quot;;\n // If versionNumber exists as Composition.ch-ext-epr-versionnumber, then map to ClinicalDocument.versionNumber\n composition.extension as ext where $this.url = 'http://fhir.ch/ig/ch-core/StructureDefinition/ch-ext-epr-versionnumber' -&gt; cda.versionNumber as versionNumber then {\n ext.valueUnsignedInt as valueUnsignedInt then IntegerINT(valueUnsignedInt, versionNumber) &quot;IntegerInt&quot;;\n } &quot;versionNumberMapped&quot;;\n // If versionNumber doesn't exist, create ClinicalDocument.versionNumber = 1\n composition as composition where $this.extension.where(url = 'http://fhir.ch/ig/ch-core/StructureDefinition/ch-ext-epr-versionnumber').exists() = false -&gt; cda.versionNumber as versionNumber then {\n composition -&gt; versionNumber.value = '1' &quot;versionNumber&quot;;\n } &quot;versionNumberCreated&quot;;\n composition.extension as extension where $this.url = 'http://fhir.ch/ig/ch-core/StructureDefinition/ch-ext-epr-informationrecipient' -&gt; cda.informationRecipient as informationRecipient then {\n extension -&gt; informationRecipient.typeCode = 'PRCP' &quot;PRCP&quot;;\n extension -&gt; informationRecipient.templateId as templateId, templateId.root = '2.16.756.5.30.1.1.10.2.4' &quot;templateId&quot;;\n extension.valueReference as valueReference then {\n bundle.entry as entry then {\n entry.fullUrl where ($this in %valueReference.reference) and $this.startsWith('urn:uuid') then {\n entry.resource : Patient as patient -&gt; informationRecipient.intendedRecipient as intendedRecipient share intendedRecipient then {\n patient.address as address -&gt; intendedRecipient.addr as addr then AddressAD(address, addr);\n patient.name as humanname -&gt; intendedRecipient.informationRecipient as informationRecipient2, informationRecipient2.name as en then HumanNameEN(humanname, en);\n } &quot;fullUrlPatient&quot;;\n entry.resource : Organization as organization -&gt; informationRecipient.intendedRecipient as intendedRecipient share intendedRecipient, intendedRecipient.receivedOrganization as receivedOrganization then Organization2CdaOrganization(organization, receivedOrganization) &quot;organization&quot;;\n } &quot;uuid&quot;;\n entry.resource : Patient as patient where (($this.id = %valueReference.reference.substring(8)) or ($this.id = %valueReference.reference.substring(9))) -&gt; informationRecipient.intendedRecipient as intendedRecipient share intendedRecipient then {\n patient.address as address -&gt; intendedRecipient.addr as addr then AddressAD(address, addr);\n patient.name as humanname -&gt; intendedRecipient.informationRecipient as informationRecipient2, informationRecipient2.name as en then HumanNameEN(humanname, en);\n } &quot;intendedRecipient&quot;;\n entry.resource : Organization as organization where (($this.id = %valueReference.reference.substring(13)) or ($this.id = %valueReference.reference.substring(9))) -&gt; informationRecipient.intendedRecipient as intendedRecipient share intendedRecipient, intendedRecipient.receivedOrganization as receivedOrganization then Organization2CdaOrganization(organization, receivedOrganization) &quot;organization&quot;;\n };\n };\n } &quot;informationRecipient&quot;;\n composition.extension as extension where $this.url = 'http://fhir.ch/ig/ch-core/StructureDefinition/ch-ext-epr-dataenterer' -&gt; cda.dataEnterer as dataEnterer then {\n extension -&gt; dataEnterer.templateId as templateId, templateId.root = '2.16.756.5.30.1.1.10.2.7' &quot;templateId&quot;;\n extension.extension as extensionTime where $this.url = 'http://fhir.ch/ig/ch-core/StructureDefinition/ch-ext-epr-time' then {\n extensionTime.valueDateTime as valueDateTime -&gt; dataEnterer.time as time then DateTimeTS(valueDateTime, time) &quot;DateTime&quot;;\n } &quot;extensionTime&quot;;\n extension.extension as extensionPerson where $this.url = 'enterer' then {\n extensionPerson.valueReference as valueReference then {\n bundle.entry as entry then {\n entry.fullUrl where ($this in %valueReference.reference) and $this.startsWith('urn:uuid') then {\n entry.resource : PractitionerRole as practitionerRole -&gt; dataEnterer.assignedEntity as assignedEntity then DataEnterer(bundle, practitionerRole, assignedEntity) &quot;AssignedEntityWithId&quot;;\n } &quot;uuid&quot;;\n entry.resource : PractitionerRole as practitionerRole where ('PractitionerRole' + '/' + $this.id) in %valueReference.reference -&gt; dataEnterer.assignedEntity as assignedEntity then DataEnterer(bundle, practitionerRole, assignedEntity) &quot;AssignedEntityWithId&quot;;\n } &quot;practitioner&quot;;\n };\n } &quot;extensionPerson&quot;;\n } &quot;dataEnterer&quot;;\n}\n\n</pre>\n </div>"
  },
  "url" : "http://fhir.ch/ig/cda-fhir-maps/StructureMap/BundleToCdaCh",
  "version" : "0.3.0",
  "name" : "BundleToCdaCh",
  "status" : "draft",
  "date" : "2022-02-11T11:14:39+01:00",
  "publisher" : "ahdis",
  "contact" : [
    {
      "name" : "ahdis",
      "telecom" : [
        {
          "system" : "url",
          "value" : "http://www.ahdis.ch/"
        }
      ]
    }
  ],
  "description" : "\r\nCDA-CH document, 2.16.756.5.30.1.1.10.1.14\r\n2020-01-16 Oliver Egger, copyright ahdis ag, Apache License\r\nCDA-CH: https://art-decor.org/art-decor/decor-templates--hl7chcda-\r\nFHIR CH-Core: http://fhir.ch/ig/ch-core/index.html\r\n",
  "copyright" : "CC-BY-SA-4.0",
  "structure" : [
    {
      "url" : "http://hl7.org/fhir/cda/StructureDefinition/ClinicalDocument",
      "mode" : "target",
      "alias" : "ClinicalDocument"
    },
    {
      "url" : "http://hl7.org/fhir/cda/StructureDefinition/Author",
      "mode" : "target",
      "alias" : "Author"
    },
    {
      "url" : "http://hl7.org/fhir/cda/StructureDefinition/RecordTarget",
      "mode" : "target",
      "alias" : "RecordTarget"
    },
    {
      "url" : "http://hl7.org/fhir/cda/StructureDefinition/DataEnterer",
      "mode" : "target",
      "alias" : "DataEnterer"
    },
    {
      "url" : "http://hl7.org/fhir/cda/StructureDefinition/AssignedEntity",
      "mode" : "target",
      "alias" : "AssignedEntity"
    },
    {
      "url" : "http://hl7.org/fhir/StructureDefinition/Bundle",
      "mode" : "source",
      "alias" : "Bundle"
    },
    {
      "url" : "http://hl7.org/fhir/StructureDefinition/Composition",
      "mode" : "source",
      "alias" : "Composition"
    },
    {
      "url" : "http://hl7.org/fhir/StructureDefinition/Person",
      "mode" : "source",
      "alias" : "Person"
    }
  ],
  "import" : [
    "http://fhir.ch/ig/cda-fhir-maps/StructureMap/FhirToCdaTypes",
    "http://fhir.ch/ig/cda-fhir-maps/StructureMap/BundleToCda"
  ],
  "group" : [
    {
      "name" : "BundleToCdaCh",
      "typeMode" : "none",
      "documentation" : "source: http://build.fhir.org/ig/hl7ch/ch-core/branches/master/StructureDefinition-ch-core-document.html\r\ntarget: https://art-decor.org/art-decor/decor-templates--hl7chcda-?id=2.16.756.5.30.1.1.10.1.14",
      "input" : [
        {
          "name" : "bundle",
          "type" : "Bundle",
          "mode" : "source"
        },
        {
          "name" : "cda",
          "type" : "ClinicalDocument",
          "mode" : "target"
        }
      ],
      "rule" : [
        {
          "name" : "bundle",
          "source" : [
            {
              "context" : "bundle"
            }
          ],
          "target" : [
            {
              "context" : "cda",
              "contextType" : "variable",
              "element" : "recordTarget",
              "variable" : "recordTarget"
            },
            {
              "context" : "cda",
              "contextType" : "variable",
              "element" : "author",
              "variable" : "author"
            }
          ],
          "dependent" : [
            {
              "name" : "BundleToClinicalDocumentCh",
              "variable" : [
                "bundle",
                "recordTarget",
                "author",
                "cda"
              ]
            }
          ]
        }
      ]
    },
    {
      "name" : "BundleToClinicalDocumentCh",
      "extends" : "BundleToClinicalDocument",
      "typeMode" : "none",
      "documentation" : "source: http://build.fhir.org/ig/hl7ch/ch-core/branches/master/StructureDefinition-ch-core-document.html\r\ntarget: https://art-decor.org/art-decor/decor-templates--hl7chcda-?id=2.16.756.5.30.1.1.10.1.14",
      "input" : [
        {
          "name" : "bundle",
          "type" : "Bundle",
          "mode" : "source"
        },
        {
          "name" : "recordTarget",
          "type" : "RecordTarget",
          "mode" : "target"
        },
        {
          "name" : "author",
          "type" : "Author",
          "mode" : "target"
        },
        {
          "name" : "cda",
          "type" : "ClinicalDocument",
          "mode" : "target"
        }
      ],
      "rule" : [
        {
          "name" : "tempalteId",
          "source" : [
            {
              "context" : "bundle"
            }
          ],
          "target" : [
            {
              "context" : "author",
              "contextType" : "variable",
              "element" : "templateId",
              "variable" : "templateId"
            },
            {
              "context" : "templateId",
              "contextType" : "variable",
              "element" : "root",
              "transform" : "copy",
              "parameter" : [
                {
                  "valueString" : "2.16.756.5.30.1.1.10.9.23"
                }
              ]
            }
          ]
        },
        {
          "name" : "tempalteId",
          "source" : [
            {
              "context" : "bundle"
            }
          ],
          "target" : [
            {
              "context" : "recordTarget",
              "contextType" : "variable",
              "element" : "templateId",
              "variable" : "templateId"
            },
            {
              "context" : "templateId",
              "contextType" : "variable",
              "element" : "root",
              "transform" : "copy",
              "parameter" : [
                {
                  "valueString" : "2.16.756.5.30.1.1.10.2.1"
                }
              ]
            }
          ]
        },
        {
          "name" : "tempalteId",
          "source" : [
            {
              "context" : "bundle"
            }
          ],
          "target" : [
            {
              "context" : "cda",
              "contextType" : "variable",
              "element" : "custodian",
              "variable" : "custodian"
            },
            {
              "context" : "custodian",
              "contextType" : "variable",
              "element" : "templateId",
              "variable" : "templateId"
            },
            {
              "context" : "templateId",
              "contextType" : "variable",
              "element" : "root",
              "transform" : "copy",
              "parameter" : [
                {
                  "valueString" : "2.16.756.5.30.1.1.10.2.3"
                }
              ]
            }
          ]
        },
        {
          "name" : "realmCode",
          "source" : [
            {
              "context" : "bundle"
            }
          ],
          "target" : [
            {
              "context" : "cda",
              "contextType" : "variable",
              "element" : "realmCode",
              "variable" : "realmCode"
            }
          ],
          "rule" : [
            {
              "name" : "CHE",
              "source" : [
                {
                  "context" : "bundle"
                }
              ],
              "target" : [
                {
                  "context" : "realmCode",
                  "contextType" : "variable",
                  "element" : "code",
                  "transform" : "copy",
                  "parameter" : [
                    {
                      "valueString" : "CHE"
                    }
                  ]
                }
              ]
            }
          ]
        },
        {
          "name" : "CDA-CHv2.0-structuredBody",
          "source" : [
            {
              "context" : "bundle"
            }
          ],
          "target" : [
            {
              "context" : "cda",
              "contextType" : "variable",
              "element" : "templateId",
              "variable" : "templateId"
            }
          ],
          "rule" : [
            {
              "name" : "root",
              "source" : [
                {
                  "context" : "bundle"
                }
              ],
              "target" : [
                {
                  "context" : "templateId",
                  "contextType" : "variable",
                  "element" : "root",
                  "transform" : "copy",
                  "parameter" : [
                    {
                      "valueString" : "2.16.756.5.30.1.1.10.1.9"
                    }
                  ]
                }
              ]
            }
          ]
        },
        {
          "name" : "HL7CdaR2-2005-containsClinicalDocument.componentAsStructuredBody",
          "source" : [
            {
              "context" : "bundle"
            }
          ],
          "target" : [
            {
              "context" : "cda",
              "contextType" : "variable",
              "element" : "templateId",
              "variable" : "templateId"
            }
          ],
          "rule" : [
            {
              "name" : "root",
              "source" : [
                {
                  "context" : "bundle"
                }
              ],
              "target" : [
                {
                  "context" : "templateId",
                  "contextType" : "variable",
                  "element" : "root",
                  "transform" : "copy",
                  "parameter" : [
                    {
                      "valueString" : "2.16.840.1.113883.10.12.2"
                    }
                  ]
                }
              ]
            }
          ]
        },
        {
          "name" : "HL7CdaR2-2005",
          "source" : [
            {
              "context" : "bundle"
            }
          ],
          "target" : [
            {
              "context" : "cda",
              "contextType" : "variable",
              "element" : "templateId",
              "variable" : "templateId"
            }
          ],
          "rule" : [
            {
              "name" : "root",
              "source" : [
                {
                  "context" : "bundle"
                }
              ],
              "target" : [
                {
                  "context" : "templateId",
                  "contextType" : "variable",
                  "element" : "root",
                  "transform" : "copy",
                  "parameter" : [
                    {
                      "valueString" : "2.16.840.1.113883.10.12.1"
                    }
                  ]
                }
              ]
            }
          ]
        },
        {
          "name" : "entry",
          "source" : [
            {
              "context" : "bundle",
              "element" : "entry",
              "variable" : "entry"
            }
          ],
          "rule" : [
            {
              "name" : "resource",
              "source" : [
                {
                  "context" : "entry",
                  "element" : "resource",
                  "variable" : "resource",
                  "condition" : "$this.ofType(FHIR.Composition)"
                }
              ],
              "dependent" : [
                {
                  "name" : "CompositionClinicalDocumentCH",
                  "variable" : [
                    "bundle",
                    "resource",
                    "cda"
                  ]
                }
              ]
            }
          ]
        }
      ]
    },
    {
      "name" : "SectionCdaRemarksCoded",
      "extends" : "SectionCdaSection",
      "typeMode" : "none",
      "documentation" : "_________________________ Section Level Templates _________________________\r\nsource: http://build.fhir.org/ig/hl7ch/ch-core/branches/master/StructureDefinition-ch-core-composition-definitions.html#Composition.section\r\ntarget: https://art-decor.org/art-decor/decor-templates--hl7chcda-?id=2.16.756.5.30.1.1.10.3.2",
      "input" : [
        {
          "name" : "bundle",
          "type" : "Bundle",
          "mode" : "source"
        },
        {
          "name" : "section",
          "type" : "Section",
          "mode" : "source"
        },
        {
          "name" : "cdasection",
          "type" : "CdaSection",
          "mode" : "target"
        }
      ],
      "rule" : [
        {
          "name" : "templateId",
          "source" : [
            {
              "context" : "section"
            }
          ],
          "target" : [
            {
              "context" : "cdasection",
              "contextType" : "variable",
              "element" : "templateId",
              "variable" : "templateId"
            },
            {
              "context" : "templateId",
              "contextType" : "variable",
              "element" : "root",
              "transform" : "copy",
              "parameter" : [
                {
                  "valueString" : "2.16.756.5.30.1.1.10.3.2"
                }
              ]
            }
          ]
        },
        {
          "name" : "entry",
          "source" : [
            {
              "context" : "section"
            }
          ],
          "target" : [
            {
              "context" : "cdasection",
              "contextType" : "variable",
              "element" : "entry",
              "variable" : "entry"
            },
            {
              "context" : "entry",
              "contextType" : "variable",
              "element" : "act",
              "variable" : "act"
            },
            {
              "context" : "act",
              "contextType" : "variable",
              "element" : "classCode",
              "transform" : "copy",
              "parameter" : [
                {
                  "valueString" : "ACT"
                }
              ]
            },
            {
              "context" : "act",
              "contextType" : "variable",
              "element" : "moodCode",
              "transform" : "copy",
              "parameter" : [
                {
                  "valueString" : "EVN"
                }
              ]
            }
          ],
          "rule" : [
            {
              "name" : "templateId",
              "source" : [
                {
                  "context" : "section"
                }
              ],
              "target" : [
                {
                  "context" : "act",
                  "contextType" : "variable",
                  "element" : "templateId",
                  "variable" : "templateId"
                },
                {
                  "context" : "templateId",
                  "contextType" : "variable",
                  "element" : "root",
                  "transform" : "copy",
                  "parameter" : [
                    {
                      "valueString" : "2.16.756.5.30.1.1.10.4.2"
                    }
                  ]
                }
              ]
            },
            {
              "name" : "templateId",
              "source" : [
                {
                  "context" : "section"
                }
              ],
              "target" : [
                {
                  "context" : "act",
                  "contextType" : "variable",
                  "element" : "templateId",
                  "variable" : "templateId"
                },
                {
                  "context" : "templateId",
                  "contextType" : "variable",
                  "element" : "root",
                  "transform" : "copy",
                  "parameter" : [
                    {
                      "valueString" : "2.16.840.1.113883.10.20.1.40"
                    }
                  ]
                }
              ]
            },
            {
              "name" : "templateId",
              "source" : [
                {
                  "context" : "section"
                }
              ],
              "target" : [
                {
                  "context" : "act",
                  "contextType" : "variable",
                  "element" : "templateId",
                  "variable" : "templateId"
                },
                {
                  "context" : "templateId",
                  "contextType" : "variable",
                  "element" : "root",
                  "transform" : "copy",
                  "parameter" : [
                    {
                      "valueString" : "1.3.6.1.4.1.19376.1.5.3.1.4.2"
                    }
                  ]
                }
              ]
            },
            {
              "name" : "code",
              "source" : [
                {
                  "context" : "section"
                }
              ],
              "target" : [
                {
                  "context" : "act",
                  "contextType" : "variable",
                  "element" : "code",
                  "variable" : "code"
                },
                {
                  "context" : "code",
                  "contextType" : "variable",
                  "element" : "code",
                  "transform" : "copy",
                  "parameter" : [
                    {
                      "valueString" : "48767-8"
                    }
                  ]
                },
                {
                  "context" : "code",
                  "contextType" : "variable",
                  "element" : "codeSystem",
                  "transform" : "copy",
                  "parameter" : [
                    {
                      "valueString" : "2.16.840.1.113883.6.1"
                    }
                  ]
                },
                {
                  "context" : "code",
                  "contextType" : "variable",
                  "element" : "codeSystemName",
                  "transform" : "copy",
                  "parameter" : [
                    {
                      "valueString" : "LOINC"
                    }
                  ]
                },
                {
                  "context" : "code",
                  "contextType" : "variable",
                  "element" : "displayName",
                  "transform" : "copy",
                  "parameter" : [
                    {
                      "valueString" : "Annotation comment"
                    }
                  ]
                }
              ]
            },
            {
              "name" : "section.text",
              "source" : [
                {
                  "context" : "section",
                  "element" : "text",
                  "variable" : "text"
                }
              ],
              "rule" : [
                {
                  "name" : "id",
                  "source" : [
                    {
                      "context" : "text",
                      "element" : "div",
                      "variable" : "div"
                    }
                  ],
                  "target" : [
                    {
                      "context" : "act",
                      "contextType" : "variable",
                      "element" : "text",
                      "variable" : "text"
                    },
                    {
                      "context" : "text",
                      "contextType" : "variable",
                      "element" : "reference",
                      "variable" : "reference"
                    },
                    {
                      "context" : "reference",
                      "contextType" : "variable",
                      "element" : "value",
                      "transform" : "evaluate",
                      "parameter" : [
                        {
                          "valueString" : "'#' + %div.substring(%div.indexOf('id') + %div.substring(%div.indexOf('id')).indexOf('\\\"') + 1, %div.substring(%div.indexOf('id') + %div.substring(%div.indexOf('id')).indexOf('\\\"') + 1).indexOf('\\\"'))"
                        }
                      ]
                    }
                  ]
                }
              ],
              "documentation" : "<span id=\"co1\">"
            },
            {
              "name" : "completed",
              "source" : [
                {
                  "context" : "section"
                }
              ],
              "target" : [
                {
                  "context" : "act",
                  "contextType" : "variable",
                  "element" : "statusCode",
                  "variable" : "statusCode"
                },
                {
                  "context" : "statusCode",
                  "contextType" : "variable",
                  "element" : "code",
                  "transform" : "copy",
                  "parameter" : [
                    {
                      "valueString" : "completed"
                    }
                  ]
                }
              ]
            }
          ]
        }
      ]
    },
    {
      "name" : "SectionCdaOriginalRepresentationObservationMedia",
      "typeMode" : "none",
      "input" : [
        {
          "name" : "binary",
          "type" : "Binary",
          "mode" : "source"
        },
        {
          "name" : "section",
          "type" : "Section",
          "mode" : "source"
        },
        {
          "name" : "cdasection",
          "type" : "CdaSection",
          "mode" : "target"
        }
      ],
      "rule" : [
        {
          "name" : "Section",
          "source" : [
            {
              "context" : "section"
            }
          ],
          "target" : [
            {
              "context" : "cdasection",
              "contextType" : "variable",
              "element" : "text",
              "transform" : "copy",
              "parameter" : [
                {
                  "valueString" : "<div xmlns=\"http://www.w3.org/1999/xhtml\">Representation of the original view:<img src=\"pdf1\"/></div>"
                }
              ]
            }
          ]
        },
        {
          "name" : "entry",
          "source" : [
            {
              "context" : "section"
            }
          ],
          "target" : [
            {
              "context" : "cdasection",
              "contextType" : "variable",
              "element" : "entry",
              "variable" : "entry"
            }
          ],
          "rule" : [
            {
              "name" : "driv",
              "source" : [
                {
                  "context" : "binary"
                }
              ],
              "target" : [
                {
                  "context" : "entry",
                  "contextType" : "variable",
                  "element" : "typeCode",
                  "transform" : "copy",
                  "parameter" : [
                    {
                      "valueString" : "DRIV"
                    }
                  ]
                }
              ]
            },
            {
              "name" : "observationMedia",
              "source" : [
                {
                  "context" : "binary"
                }
              ],
              "target" : [
                {
                  "context" : "entry",
                  "contextType" : "variable",
                  "element" : "observationMedia",
                  "variable" : "observationMedia"
                },
                {
                  "context" : "observationMedia",
                  "contextType" : "variable",
                  "element" : "classCode",
                  "transform" : "copy",
                  "parameter" : [
                    {
                      "valueString" : "OBS"
                    }
                  ]
                },
                {
                  "context" : "observationMedia",
                  "contextType" : "variable",
                  "element" : "moodCode",
                  "transform" : "copy",
                  "parameter" : [
                    {
                      "valueString" : "EVN"
                    }
                  ]
                }
              ],
              "rule" : [
                {
                  "name" : "templateId",
                  "source" : [
                    {
                      "context" : "binary"
                    }
                  ],
                  "target" : [
                    {
                      "context" : "observationMedia",
                      "contextType" : "variable",
                      "element" : "templateId",
                      "variable" : "templateId"
                    },
                    {
                      "context" : "templateId",
                      "contextType" : "variable",
                      "element" : "root",
                      "transform" : "copy",
                      "parameter" : [
                        {
                          "valueString" : "2.16.756.5.30.1.1.10.4.83"
                        }
                      ]
                    }
                  ]
                },
                {
                  "name" : "reference",
                  "source" : [
                    {
                      "context" : "binary"
                    }
                  ],
                  "target" : [
                    {
                      "context" : "observationMedia",
                      "contextType" : "variable",
                      "element" : "ID",
                      "transform" : "copy",
                      "parameter" : [
                        {
                          "valueString" : "pdf1"
                        }
                      ]
                    }
                  ]
                },
                {
                  "name" : "value",
                  "source" : [
                    {
                      "context" : "binary"
                    }
                  ],
                  "target" : [
                    {
                      "context" : "observationMedia",
                      "contextType" : "variable",
                      "element" : "value",
                      "variable" : "value"
                    },
                    {
                      "context" : "value",
                      "contextType" : "variable",
                      "element" : "mediaType",
                      "transform" : "copy",
                      "parameter" : [
                        {
                          "valueString" : "2.16.756.5.30.1.1.10.4.83"
                        }
                      ]
                    },
                    {
                      "context" : "value",
                      "contextType" : "variable",
                      "element" : "representation",
                      "transform" : "copy",
                      "parameter" : [
                        {
                          "valueString" : "B64"
                        }
                      ]
                    }
                  ],
                  "rule" : [
                    {
                      "name" : "contentType",
                      "source" : [
                        {
                          "context" : "binary",
                          "element" : "contentType",
                          "variable" : "contentType"
                        }
                      ],
                      "target" : [
                        {
                          "context" : "value",
                          "contextType" : "variable",
                          "element" : "mediaType",
                          "transform" : "copy",
                          "parameter" : [
                            {
                              "valueId" : "contentType"
                            }
                          ]
                        }
                      ]
                    },
                    {
                      "name" : "data",
                      "source" : [
                        {
                          "context" : "binary",
                          "element" : "data",
                          "variable" : "data"
                        }
                      ],
                      "target" : [
                        {
                          "context" : "value",
                          "contextType" : "variable",
                          "element" : "data",
                          "transform" : "copy",
                          "parameter" : [
                            {
                              "valueId" : "data"
                            }
                          ]
                        }
                      ]
                    },
                    {
                      "name" : "lang",
                      "source" : [
                        {
                          "context" : "binary",
                          "element" : "language",
                          "variable" : "lang"
                        }
                      ],
                      "target" : [
                        {
                          "context" : "observationMedia",
                          "contextType" : "variable",
                          "element" : "languageCode",
                          "variable" : "languageCode"
                        },
                        {
                          "context" : "languageCode",
                          "contextType" : "variable",
                          "element" : "code",
                          "transform" : "copy",
                          "parameter" : [
                            {
                              "valueId" : "lang"
                            }
                          ]
                        }
                      ]
                    },
                    {
                      "name" : "langUnknown",
                      "source" : [
                        {
                          "context" : "binary",
                          "condition" : "$this.language.exists() = false"
                        }
                      ],
                      "target" : [
                        {
                          "context" : "observationMedia",
                          "contextType" : "variable",
                          "element" : "languageCode",
                          "variable" : "languageCode"
                        },
                        {
                          "context" : "languageCode",
                          "contextType" : "variable",
                          "element" : "nullFlavor",
                          "transform" : "copy",
                          "parameter" : [
                            {
                              "valueString" : "UNK"
                            }
                          ]
                        }
                      ]
                    }
                  ]
                }
              ]
            }
          ]
        }
      ]
    },
    {
      "name" : "SectionCdaOriginalRepresentation",
      "extends" : "SectionCdaSection",
      "typeMode" : "none",
      "documentation" : "source: http://build.fhir.org/ig/hl7ch/ch-core/branches/master/StructureDefinition-ch-core-composition-definitions.html#Composition.section\r\ntarget: https://art-decor.org/art-decor/decor-templates--hl7chcda-?id=2.16.756.5.30.1.1.10.1.14\r\ntarget: https://art-decor.org/art-decor/decor-templates--hl7chcda-?id=2.16.756.5.30.1.1.10.4.83",
      "input" : [
        {
          "name" : "bundle",
          "type" : "Bundle",
          "mode" : "source"
        },
        {
          "name" : "section",
          "type" : "Section",
          "mode" : "source"
        },
        {
          "name" : "cdasection",
          "type" : "CdaSection",
          "mode" : "target"
        }
      ],
      "rule" : [
        {
          "name" : "templateId",
          "source" : [
            {
              "context" : "section"
            }
          ],
          "target" : [
            {
              "context" : "cdasection",
              "contextType" : "variable",
              "element" : "templateId",
              "variable" : "templateId"
            },
            {
              "context" : "templateId",
              "contextType" : "variable",
              "element" : "root",
              "transform" : "copy",
              "parameter" : [
                {
                  "valueString" : "2.16.756.5.30.1.1.10.3.45"
                }
              ]
            }
          ]
        },
        {
          "name" : "defaulttitles",
          "source" : [
            {
              "context" : "section",
              "condition" : "title.exists().not()"
            }
          ],
          "rule" : [
            {
              "name" : "titleDE",
              "source" : [
                {
                  "context" : "section",
                  "condition" : "(%bundle.entry[0].resource.language.startsWith('de'))"
                }
              ],
              "target" : [
                {
                  "context" : "cdasection",
                  "contextType" : "variable",
                  "element" : "title",
                  "variable" : "title"
                },
                {
                  "context" : "title",
                  "contextType" : "variable",
                  "element" : "data",
                  "transform" : "copy",
                  "parameter" : [
                    {
                      "valueString" : "Original Darstellung"
                    }
                  ]
                }
              ]
            },
            {
              "name" : "titleFR",
              "source" : [
                {
                  "context" : "section",
                  "condition" : "(%bundle.entry[0].resource.language.startsWith('fr'))"
                }
              ],
              "target" : [
                {
                  "context" : "cdasection",
                  "contextType" : "variable",
                  "element" : "title",
                  "variable" : "title"
                },
                {
                  "context" : "title",
                  "contextType" : "variable",
                  "element" : "data",
                  "transform" : "copy",
                  "parameter" : [
                    {
                      "valueString" : "Représentation originale"
                    }
                  ]
                }
              ]
            },
            {
              "name" : "titleIT",
              "source" : [
                {
                  "context" : "section",
                  "condition" : "(%bundle.entry[0].resource.language.startsWith('it'))"
                }
              ],
              "target" : [
                {
                  "context" : "cdasection",
                  "contextType" : "variable",
                  "element" : "title",
                  "variable" : "title"
                },
                {
                  "context" : "title",
                  "contextType" : "variable",
                  "element" : "data",
                  "transform" : "copy",
                  "parameter" : [
                    {
                      "valueString" : "Rappresentazione originale"
                    }
                  ]
                }
              ]
            },
            {
              "name" : "titleEN",
              "source" : [
                {
                  "context" : "section",
                  "condition" : "(%bundle.entry[0].resource.language.startsWith('en'))"
                }
              ],
              "target" : [
                {
                  "context" : "cdasection",
                  "contextType" : "variable",
                  "element" : "title",
                  "variable" : "title"
                },
                {
                  "context" : "title",
                  "contextType" : "variable",
                  "element" : "data",
                  "transform" : "copy",
                  "parameter" : [
                    {
                      "valueString" : "Original representation"
                    }
                  ]
                }
              ]
            }
          ]
        },
        {
          "name" : "patient",
          "source" : [
            {
              "context" : "bundle",
              "element" : "entry",
              "variable" : "entry"
            }
          ],
          "rule" : [
            {
              "name" : "fullUrlAsUuid",
              "source" : [
                {
                  "context" : "entry",
                  "element" : "fullUrl",
                  "condition" : "($this in %section.entry.reference) and $this.startsWith('urn:uuid')"
                }
              ],
              "rule" : [
                {
                  "name" : "patient",
                  "source" : [
                    {
                      "context" : "entry",
                      "element" : "resource",
                      "variable" : "binary"
                    }
                  ],
                  "dependent" : [
                    {
                      "name" : "SectionCdaOriginalRepresentationObservationMedia",
                      "variable" : [
                        "binary",
                        "section",
                        "cdasection"
                      ]
                    }
                  ]
                }
              ]
            },
            {
              "name" : "patient",
              "source" : [
                {
                  "context" : "entry",
                  "element" : "resource",
                  "variable" : "binary",
                  "condition" : "('Binary' + '/' + $this.id) in %section.entry.reference"
                }
              ],
              "dependent" : [
                {
                  "name" : "SectionCdaOriginalRepresentationObservationMedia",
                  "variable" : [
                    "binary",
                    "section",
                    "cdasection"
                  ]
                }
              ]
            }
          ]
        }
      ]
    },
    {
      "name" : "PersonAssignedEntityWithId",
      "typeMode" : "none",
      "documentation" : "_________________________ Entry Level Templates ________________________\r\n_________________________ Header Level Templates _________________________\r\nsource: http://build.fhir.org/ig/hl7ch/ch-core/branches/master/StructureDefinition-ch-core-composition-epr.html\r\ntarget: https://art-decor.org/art-decor/decor-templates--hl7chcda-?id=2.16.756.5.30.1.1.10.9.12",
      "input" : [
        {
          "name" : "practitioner",
          "type" : "Practitioner",
          "mode" : "source"
        },
        {
          "name" : "assignedEntity",
          "type" : "AssignedEntity",
          "mode" : "target"
        }
      ],
      "rule" : [
        {
          "name" : "identifier",
          "source" : [
            {
              "context" : "practitioner",
              "element" : "identifier",
              "variable" : "identifier"
            }
          ],
          "target" : [
            {
              "context" : "assignedEntity",
              "contextType" : "variable",
              "element" : "id",
              "variable" : "id"
            }
          ],
          "dependent" : [
            {
              "name" : "IdentifierII",
              "variable" : [
                "identifier",
                "id"
              ]
            }
          ]
        },
        {
          "name" : "address",
          "source" : [
            {
              "context" : "practitioner",
              "element" : "address",
              "variable" : "address"
            }
          ],
          "target" : [
            {
              "context" : "assignedEntity",
              "contextType" : "variable",
              "element" : "addr",
              "variable" : "addr"
            }
          ],
          "dependent" : [
            {
              "name" : "AddressAD",
              "variable" : [
                "address",
                "addr"
              ]
            }
          ]
        },
        {
          "name" : "name",
          "source" : [
            {
              "context" : "practitioner",
              "element" : "name",
              "variable" : "humanname"
            }
          ],
          "target" : [
            {
              "context" : "assignedEntity",
              "contextType" : "variable",
              "element" : "assignedPerson",
              "variable" : "assignedPerson"
            },
            {
              "context" : "assignedPerson",
              "contextType" : "variable",
              "element" : "name",
              "variable" : "en"
            }
          ],
          "dependent" : [
            {
              "name" : "HumanNameEN",
              "variable" : [
                "humanname",
                "en"
              ]
            }
          ]
        }
      ]
    },
    {
      "name" : "DataEnterer",
      "typeMode" : "none",
      "documentation" : "source: http://build.fhir.org/ig/hl7ch/ch-core/branches/master/StructureDefinition-ch-core-composition-epr.html\r\ntarget: https://art-decor.org/art-decor/decor-templates--hl7chcda-?id=2.16.756.5.30.1.1.10.9.12",
      "input" : [
        {
          "name" : "bundle",
          "type" : "Bundle",
          "mode" : "source"
        },
        {
          "name" : "practitionerRole",
          "type" : "PractitionerRole",
          "mode" : "source"
        },
        {
          "name" : "assignedEntity",
          "type" : "AssignedEntity",
          "mode" : "target"
        }
      ],
      "rule" : [
        {
          "name" : "extensionPerson",
          "source" : [
            {
              "context" : "practitionerRole",
              "element" : "practitioner",
              "variable" : "practitioner"
            }
          ],
          "rule" : [
            {
              "name" : "valueReference",
              "source" : [
                {
                  "context" : "practitioner",
                  "element" : "reference",
                  "variable" : "reference"
                }
              ],
              "rule" : [
                {
                  "name" : "practitioner",
                  "source" : [
                    {
                      "context" : "bundle",
                      "element" : "entry",
                      "variable" : "entry"
                    }
                  ],
                  "rule" : [
                    {
                      "name" : "uuid",
                      "source" : [
                        {
                          "context" : "entry",
                          "element" : "fullUrl",
                          "condition" : "($this in %reference.value) and $this.startsWith('urn:uuid')"
                        }
                      ],
                      "rule" : [
                        {
                          "name" : "AssignedEntityWithId",
                          "source" : [
                            {
                              "context" : "entry",
                              "type" : "Practitioner",
                              "element" : "resource",
                              "variable" : "practitioner"
                            }
                          ],
                          "dependent" : [
                            {
                              "name" : "PersonAssignedEntityWithId",
                              "variable" : [
                                "practitioner",
                                "assignedEntity"
                              ]
                            }
                          ]
                        }
                      ]
                    },
                    {
                      "name" : "AssignedEntityWithId",
                      "source" : [
                        {
                          "context" : "entry",
                          "type" : "Practitioner",
                          "element" : "resource",
                          "variable" : "practitioner",
                          "condition" : "('Practitioner' + '/' + $this.id) in %reference.value"
                        }
                      ],
                      "dependent" : [
                        {
                          "name" : "PersonAssignedEntityWithId",
                          "variable" : [
                            "practitioner",
                            "assignedEntity"
                          ]
                        }
                      ]
                    }
                  ]
                }
              ]
            }
          ]
        },
        {
          "name" : "extensionPerson",
          "source" : [
            {
              "context" : "practitionerRole",
              "element" : "organization",
              "variable" : "organization"
            }
          ],
          "target" : [
            {
              "context" : "assignedEntity",
              "contextType" : "variable",
              "element" : "representedOrganization",
              "variable" : "representedOrganization"
            }
          ],
          "rule" : [
            {
              "name" : "valueReference",
              "source" : [
                {
                  "context" : "organization",
                  "element" : "reference",
                  "variable" : "reference"
                }
              ],
              "rule" : [
                {
                  "name" : "practitioner",
                  "source" : [
                    {
                      "context" : "bundle",
                      "element" : "entry",
                      "variable" : "entry"
                    }
                  ],
                  "rule" : [
                    {
                      "name" : "uuid",
                      "source" : [
                        {
                          "context" : "entry",
                          "element" : "fullUrl",
                          "condition" : "($this in %reference.value) and $this.startsWith('urn:uuid')"
                        }
                      ],
                      "rule" : [
                        {
                          "name" : "representedOrganization",
                          "source" : [
                            {
                              "context" : "entry",
                              "type" : "Organization",
                              "element" : "resource",
                              "variable" : "organization"
                            }
                          ],
                          "dependent" : [
                            {
                              "name" : "Organization2CdaOrganization",
                              "variable" : [
                                "organization",
                                "representedOrganization"
                              ]
                            }
                          ]
                        }
                      ]
                    },
                    {
                      "name" : "representedOrganization",
                      "source" : [
                        {
                          "context" : "entry",
                          "type" : "Organization",
                          "element" : "resource",
                          "variable" : "organization",
                          "condition" : "('Organization' + '/' + $this.id) in %reference.value"
                        }
                      ],
                      "dependent" : [
                        {
                          "name" : "Organization2CdaOrganization",
                          "variable" : [
                            "organization",
                            "representedOrganization"
                          ]
                        }
                      ]
                    }
                  ]
                }
              ]
            }
          ]
        }
      ]
    },
    {
      "name" : "CompositionClinicalDocumentCH",
      "typeMode" : "none",
      "documentation" : "_________________________ Template Type not specified ___________________\r\nsource: http://hl7.org/fhir/R4/person.html\r\ntarget: https://art-decor.org/art-decor/decor-templates--hl7chcda-?id=2.16.756.5.30.1.1.10.9.36",
      "input" : [
        {
          "name" : "bundle",
          "type" : "Bundle",
          "mode" : "source"
        },
        {
          "name" : "composition",
          "type" : "Composition",
          "mode" : "source"
        },
        {
          "name" : "cda",
          "type" : "ClinicalDocument",
          "mode" : "target"
        }
      ],
      "rule" : [
        {
          "name" : "type",
          "source" : [
            {
              "context" : "composition",
              "element" : "type",
              "variable" : "type"
            }
          ],
          "rule" : [
            {
              "name" : "translation",
              "source" : [
                {
                  "context" : "type",
                  "element" : "coding",
                  "variable" : "coding",
                  "condition" : "$this.system = 'http://snomed.info/sct'"
                }
              ],
              "target" : [
                {
                  "context" : "cda",
                  "contextType" : "variable",
                  "element" : "code",
                  "variable" : "code"
                },
                {
                  "context" : "code",
                  "contextType" : "variable",
                  "element" : "translation",
                  "variable" : "translation"
                }
              ],
              "dependent" : [
                {
                  "name" : "CodingCE",
                  "variable" : [
                    "coding",
                    "translation"
                  ]
                }
              ]
            }
          ]
        },
        {
          "name" : "confidentialityCode",
          "source" : [
            {
              "context" : "composition",
              "element" : "confidentiality",
              "variable" : "conf",
              "condition" : "$this.extension.where(url = 'http://fhir.ch/ig/ch-core/StructureDefinition/ch-ext-epr-confidentialitycode').exists()"
            }
          ],
          "target" : [
            {
              "context" : "cda",
              "contextType" : "variable",
              "element" : "confidentialityCode",
              "variable" : "cdaconf"
            }
          ],
          "rule" : [
            {
              "name" : "extension",
              "source" : [
                {
                  "context" : "conf",
                  "element" : "extension",
                  "variable" : "extension"
                }
              ],
              "rule" : [
                {
                  "name" : "valueCodeableConcept",
                  "source" : [
                    {
                      "context" : "extension",
                      "element" : "valueCodeableConcept",
                      "variable" : "valueCodeableConcept"
                    }
                  ],
                  "rule" : [
                    {
                      "name" : "coding",
                      "source" : [
                        {
                          "context" : "valueCodeableConcept",
                          "element" : "coding",
                          "variable" : "coding"
                        }
                      ],
                      "dependent" : [
                        {
                          "name" : "CodingCE",
                          "variable" : [
                            "coding",
                            "cdaconf"
                          ]
                        }
                      ]
                    }
                  ]
                }
              ]
            }
          ]
        },
        {
          "name" : "IdentifierII",
          "source" : [
            {
              "context" : "composition",
              "element" : "identifier",
              "variable" : "identifier",
              "condition" : "$this.system = 'urn:ietf:rfc:3986'"
            }
          ],
          "target" : [
            {
              "context" : "cda",
              "contextType" : "variable",
              "element" : "setId",
              "variable" : "setId"
            }
          ],
          "dependent" : [
            {
              "name" : "IdentifierII",
              "variable" : [
                "identifier",
                "setId"
              ]
            }
          ],
          "documentation" : "If setId exists as Composition.ch-ext-epr-setid, then map to ClinicalDocument.setId"
        },
        {
          "name" : "setIdCreated",
          "source" : [
            {
              "context" : "composition",
              "condition" : "$this.identifier.where(system = 'urn:ietf:rfc:3986').exists() = false"
            }
          ],
          "rule" : [
            {
              "name" : "setId",
              "source" : [
                {
                  "context" : "bundle",
                  "element" : "identifier",
                  "variable" : "identifier"
                }
              ],
              "target" : [
                {
                  "context" : "cda",
                  "contextType" : "variable",
                  "element" : "setId",
                  "variable" : "id"
                }
              ],
              "dependent" : [
                {
                  "name" : "IdentifierII",
                  "variable" : [
                    "identifier",
                    "id"
                  ]
                }
              ]
            }
          ],
          "documentation" : "If setId       "source" : [
                                {
                                  "context" : "entry",
                                  "type" : "PractitionerRole",
                                  "element" : "resource",
                                  "variable" : "practitionerRole"
                                }
                              ],
                              "target" : [
                                {
                                  "context" : "dataEnterer",
                                  "contextType" : "variable",
                                  "element" : "assignedEntity",
                                  "variable" : "assignedEntity"
                                }
                              ],
                              "dependent" : [
                                {
                                  "name" : "DataEnterer",
                                  "variable" : [
                                    "bundle",
                                    "practitionerRole",
                                    "assignedEntity"
                                  ]
                                }
                              ]
                            }
                          ]
                        },
                        {
                          "name" : "AssignedEntityWithId",
                          "source" : [
                            {
                              "context" : "entry",
                              "type" : "PractitionerRole",
                              "element" : "resource",
                              "variable" : "practitionerRole",
                              "condition" : "('PractitionerRole' + '/' + $this.id) in %valueReference.reference"
                            }
                          ],
                          "target" : [
                            {
                              "context" : "dataEnterer",
                              "contextType" : "variable",
                              "element" : "assignedEntity",
                              "variable" : "assignedEntity"
                            }
                          ],
                          "dependent" : [
                            {
                              "name" : "DataEnterer",
                              "variable" : [
                                "bundle",
                                "practitionerRole",
                                "assignedEntity"
                              ]
                            }
                          ]
                        }
                      ]
                    }
                  ]
                }
              ]
            }
          ]
        }
      ]
    }
  ]
}

XIG built as of ??metadata-date??. Found ??metadata-resources?? resources in ??metadata-packages?? packages.